package com.weaponlin.domain;

import java.util.ArrayList;
import java.util.Iterator;

public class VolatileTest {

    private static volatile int value = 0;

    public static void main(String[] args) {
//        System.out.println("begin: " + value);
//        IntStream.range(0, 100).forEach(e -> {
//            new Thread(() -> ++value).start();
//        });
//        System.out.println("end: " + value);
//

        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(5);
        list.add(1);
        list.add(3);
        list.forEach(System.out::println);
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            if (iterator.next() == 1) {
                iterator.remove();
            }
        }
        System.out.println("=================");
        list.forEach(System.out::println);
    }
}
